package com.ruoyi.ai.service.impl;

import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.ruoyi.ai.service.ChatService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class ChatServiceImpl implements ChatService {

    /**
     * 通义千问key
     */
    @Value("${tyqwApiKey}")
    public  String apiKey;
    /**
     * 提问前缀
     */
    @Value("${aiMSG}")
    private String question;
    @Override
    public GenerationResult chatAi() throws NoApiKeyException, InputRequiredException {
        return  QianWenChat.callWithMessage(apiKey);
    }

    @Override
    public GenerationResult chatAi(String msg) throws NoApiKeyException, InputRequiredException {
        return QianWenChat.callWithMessage(question+msg,apiKey);
    }
}
